python排列组合,范数, 中位数相关函数

import numpy as np
a = np.array([1, 2, 3])
np.linalg.norm(a, 1) #1-范数
np.linalg.norm(a, 2) #2-范数

x = np.array([1, 2])
y = np.array([1, 4])
dist = np.linalg.norm(x-y, 2) # x,y之间的欧里几德距离

[latex]C_{5}^2[/latex]

from scipy.special import comb
comb(5, 2) # output: 10

[latex]A_{5}^2[/latex]

from scipy.special import perm
perm(5, 2) # output: 20

中位数

x = np.array([1, 2, 5, 4, 9, 0, 6])
np.median(x)  # 4

阶乘[latex]k![/latex]

from scipy.special import factorial
factorial(6) # out :array(720.0)